﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using PPI.Entities.Remedy;
using VMind.Global;

namespace PPI.Client.Logic
{
    public class LRemedyStatus
    {
        public static List<ERemedyStatus> SelectAll()
        {
            List<ERemedyStatus> listRemedyStatus = new List<ERemedyStatus>();
            DataSet ds = WebConsumer.Remedy.WRemedyStatus.GetAll();
            if(ds != null)
            {
                DataTable dtRemedyStatus = ds.Tables[0];
                listRemedyStatus = ParseDatatableRemedyStatus(dtRemedyStatus);
            }
            return listRemedyStatus;
           
        }

        private static List<ERemedyStatus> ParseDatatableRemedyStatus(DataTable dtRemedyStatus)
        {
            List<ERemedyStatus> listRemedyStatus = new List<ERemedyStatus>();
            foreach (DataRow dr in dtRemedyStatus.Rows)
            {
                ERemedyStatus tmpRemedyStatus = new ERemedyStatus();
                tmpRemedyStatus.Id = ConvertHelper.ToInt32(dr["RemedyStatusId"]);
                tmpRemedyStatus.Name = dr["Name"].ToString();
                listRemedyStatus.Add(tmpRemedyStatus);
            }
            return listRemedyStatus;
        }
    }
}
